package com.smallframework.mvc;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * User: Administrator
 * DateTime: 2017/7/2 0002 16:43
 */
public class ClassHelper {
	private String basePacakage;

	public List<Class<?>> getClassesByAnnotation(Class<? extends Annotation> annotationClass) {

		try {
			return ClassUtil.getClassesByAnnotation(basePacakage, annotationClass);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return new ArrayList<>();
	}

	public List<Class<?>> getClassesByAnnotations(List<Class<? extends Annotation>> annotationClasses) {
		List<Class<?>> classes = new ArrayList<>();
		try {
			for (Class<? extends Annotation> annotationClass : annotationClasses) {
				classes.addAll(ClassUtil.getClassesByAnnotation(basePacakage, annotationClass));
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return classes;
	}

	public List<Class<?>> getAllClasses() {
		try {
			return ClassUtil.getAllClass(basePacakage, true);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return new ArrayList<>();
	}

	public String getBasePacakage() {
		return basePacakage;
	}

	public void setBasePacakage(String basePacakage) {
		this.basePacakage = basePacakage;
	}
}
